package com.furongji.education.controller.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.furongji.education.domain.po.Teacher;
import com.furongji.common.domain.query.TeacherQuery;
import com.furongji.common.result.Result;
import com.furongji.education.service.CourseService;
import com.furongji.education.service.TeacherService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "用户端讲师数据")
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/courses")
public class TeacherApiController {

    private final TeacherService teacherService;

    private final CourseService courseService;

    @Operation(summary = "用户端查询讲师")
    @PostMapping("/pageTeacherCondition/{current}/{size}")
    public Result pageTeacherCondition(@PathVariable Integer current, @PathVariable Integer size,
                                       @RequestBody(required = false) TeacherQuery teacherQuery) {

        IPage<Teacher> page = new Page<>(current, size);
        IPage<Teacher> result = teacherService.pageQuery(page, new TeacherQuery());
        return Result.success(result);
    }

    @Operation(summary = "用户端讲师详情")
    @GetMapping("/getTeacherInfo/{teacherId}")
    public Result getTeacherInfo(@PathVariable String teacherId) {
        Map<String, Object> mapResult = teacherService.getApiTeacherInfo(teacherId);
        return Result.success(mapResult);
    }

}
